package com.framework.utils;

import java.io.File;
import java.io.IOException;
import java.util.*;
import java.util.regex.Matcher;

import org.mybatis.generator.api.MyBatisGenerator;
import org.mybatis.generator.config.Configuration;
import org.mybatis.generator.config.xml.ConfigurationParser;
import org.mybatis.generator.exception.XMLParserException;
import org.mybatis.generator.internal.DefaultShellCallback;

public class GeneratorSqlmap {

    public static void generator(String database, String tableNames, String domainObjectNames) {
        try {
            Dom4JXML.DOM$J(database, tableNames, domainObjectNames);
            List<String> warnings = new ArrayList<String>();
            boolean overwrite = true;
            // 指定配置文件
            File configFile = new File("F:\\MyProject\\universal-framework\\framework-generator\\src\\main\\resources\\generatorConfig.xml");
            ConfigurationParser cp = new ConfigurationParser(warnings);
            Configuration config = null;
            config = cp.parseConfiguration(configFile);
            DefaultShellCallback callback = new DefaultShellCallback(overwrite);
            MyBatisGenerator myBatisGenerator = new MyBatisGenerator(config, callback, warnings);
            myBatisGenerator.generate(null);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

  /*  // 执行main方法以生成代码
    public static void main(String[] args) {
        String name[] = {"itf_engine", "pr_user"};
        for (int i = 0; i < name.length; i++) {
            GeneratorSqlmap.generator(name[i], Tool.underline2Camel(name[i] + "DO", true));
        }
    }*/
}